<?php

namespace Modules\Admin\Services;

use Illuminate\Http\JsonResponse;
use Modules\Admin\Models\AuthGroup;
use Modules\Common\StatusData;

class AuthGroupService extends BaseService
{
    protected $model = null;

    public function __construct()
    {
        $this->model = new AuthGroup();
    }

    public function list(): JsonResponse
    {
        $list = $this->model->simplePaginate();
        return $this->buildSuccess($list->toArray());
    }

    /**
     * 添加操作
     * @param array $data
     * @return JsonResponse
     */
    public function store(Array $data): JsonResponse
    {

       $result =  $this->model->create($data);
       if ($result === false){
           return $this->buildFailed(StatusData::DB_SAVE_ERROR);
       }
       return $this->buildSuccess();
    }
}
